<?php

namespace Trawind\Basics\Model;


use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use Trawind\Basics\Enums\SystemConstant;
use Trawind\Basics\Traits\AutoMaintainOperator;

/**
 * @method Builder active
 * @package Trawind\Basics\Model
 */
class BaseTenantModel extends Model implements Transformable
{

    use TransformableTrait, AutoMaintainOperator;

    public $businessType;
    
    public static $businessTypeId;

    protected $guarded = ['created_at', 'updated_at'];

    protected $dateFormat = 'U';

    protected $maintainUser = true;

    protected $writeLogSwitch = true;

    /**
     * @note  未作废的作用域
     * @param  Builder  $query
     * @return Builder
     */
    public function scopeActive($query): Builder
    {
        return $query->where('status_type_id', '<>', SystemConstant::STATUS_INVALID);
    }
}